package club.jdiy.core.convert;

import java.math.BigDecimal;
import java.math.BigInteger;

class BooleanConverter extends Converter {
    private final Boolean source;

    public BooleanConverter(Boolean source) {
        this.source = source != null && source;
    }

    @Override
    public Boolean getSource() {
        return source;
    }

    @Override
    public Boolean getBoolean() {
        return source;
    }

    @Override
    public Byte getByte() {
        return (byte) (source ? 1 : 0);
    }

    @Override
    public Short getShort() {
        return (short) (source ? 1 : 0);
    }

    @Override
    public Integer getInteger() {
        return source ? 1 : 0;
    }

    @Override
    public Long getLong() {
        return source ? 1L : 0L;
    }

    @Override
    public Float getFloat() {
        return source ? 1F : 0F;
    }

    @Override
    public Double getDouble() {
        return source ? 1D : 0D;
    }

    @Override
    public String getString() {
        return source ? "1" : "0";
    }

    @Override
    public BigDecimal getBigDecimal() {
        return source ? BigDecimal.ONE : BigDecimal.ZERO;
    }

    @Override
    public BigInteger getBigInteger() {
        return source ? BigInteger.ONE : BigInteger.ZERO;
    }

}
